

package chapter8;

public class MyOuterClass {
	
	private int x=8;
	
	public static void main (String[] args){
		//MyOuterClass moc = new MyOuterClass();
		//moc.makeInner();
		MyOuterClass.MyInnerClass in = new MyOuterClass().new MyInnerClass();
		in.seeOuter();
	}
	public void makeInner(){
		MyInnerClass in = new MyInnerClass();
		in.seeOuter();
	}
	//inner class definition
	//inner class is scoped outside any method code
	//at the same level as an instance variable is declared
	public class MyInnerClass{
		public void seeOuter(){
			System.out.println("Outer x is "+x);
			System.out.println("Outer class ref is "+MyOuterClass.this);
			System.out.println("Inner class ref is "+this);
		}
	}//close of inner class
}//close of outer class
